Copyright: Copyright (c) 1994 Pragma Pty Ltd.


Date/time edit control
 Date/Time Edit

Properties	Methods	Events	New Features	About

Description

The date/time edit control provides for editing of valid date and time values. A typical problem that faces the application developer is how to detect and handle the situation where an invalid date is entered. By using this control, an application user is unable to enter an invalid date or time value. This is an example of a date/time edit control.

The spin buttons are used to increment or decrement the selected part of the date time. In the above example the seconds are selected, but any of the other date/time parts may be selected either by use of the mouse or the cursor positioning keys.

File Name

DTEDIT.VBX

Object Type

DateEdit

Remarks

The date/time custom control has a number of custom properties that allow you to specifiy the format of the date/time to be displayed. A single custom event is supplied that is fired whenever the date/time in the control is modified.

Distribution Note	When you create and distribute applications that use the date/time edit custom control, you should install the file DTEDIT.VBX in the customer's Microsoft Windows \SYSTEM subdirectory. The setup kit included with Visual Basic provides tools that help you write setup programs that install your applications correctly.


About Date/Time Control
About DTEDIT.VBX

Date/Time Edit Custom Control

Copyright © 1994 Pragma Pty Ltd. All rights reserved.
Written by John Jeffery

To purchase this product from CompuServe, type "GO SWREG" and quote registration #3582

If you require further information, or would like to make a suggestion, please contact the author by fax or e-mail:

Fax (International):	+61 7 841 1977

Fax (Australia):	(07) 841 1977

Compuserve ID:	100237,3000

Internet e-mail:	100237.3000@compuserve.com


Date/Edit Control Properties
Properties

All of the properties for this control are listed in the following table. Properties that apply only to the date/time edit control, or that require special consideration when used with it, are marked with an asterix (*). For documentation on the remaining properties, refer to the Visual Basic Language Reference.

*Alignment	FontItalic	*Language	TabStop
BackColor	FontName	Left	Tag
BorderStyle	FontSize	LinkItem	*Text
DataChanged	FontStrikethru	LinkMode	*TimeResolution
DataField	FontUnderline	LinkTimeout	*TimeSerial
DataSource	ForeColor	LinkTopic	*TimeStep
*DateSerial	*Format	*Minute	Top
*DayOfMonth	Height	*Month	Visible
*DayOfWeek	HelpContextID	MousePointer	Width
DragIcon	*Hour	Name	*WrapAround
DragMode	hWnd	*Second	*Year
Enabled	Index	*ShowButtons
FontBold	*KeyboardEntry	TabIndex


Date/Time Control Methods
Methods

All of the methods for this control are listed in the following table. For documentation,  refer to the Visual Basic Language Reference.

Clear	LinkPoke	Move	SetFocus

Drag	LinkExecute	LinkRequest	Refresh	ZOrder


Date/Time Control Events
Events

All of the events for this control are listed in the following table. Events that apply only to the date/time edit control, or that require special consideration when used with it, are marked with an asterix (*). For documentation on the remaining events, refer to the Visual Basic Language Reference.

*Change	DragOver	KeyUp	LinkOpen

Click	GotFocus	LinkClose	LostFocus

DblClick	KeyDown	LinkError	MouseDown

DragDrop	KeyPress	LinkNotify	MouseUp

MouseMove


Alignment Property

Determines the alignment of the date/time text in the control.

Usage

[form.]control.Alignment [ = numericexpression ]

Remarks

The Alignment property settings are:

Setting	Description

0	(Default) Text aligns to the left.

1	Text aligns to the right

2	Text aligns to the centre (in Microsoft Windows version 3.0 aligns to the left).

These settings are identical to those for the Alignment property associated with the standard text box control.

Data Type

Integer (Enumerated)

See Also

Discussion of Alignment property in Visual Basic Language Reference


DateSerial
DateSerial Property

Returns the currently displayed date as a date serial number compatible with the VB DateSerial function. Read-only property.

Usage

[form.]control.DateSerial

Remarks

If the date/time edit control is not currently displaying a valid date (ie it is blank),  then this property returns a negative value.

Data Type

Long integer


DayOfMonth
DayOfMonth Property

Returns the day of the month of the currently displayed date. Read-only property.

Usage

[form.]control.DayOfMonth

Remarks

If the date/time edit control is not currently displaying a valid date (ie it is blank),  then this property returns a negative value.

Data Type

Integer


DayOfWeek Property

Returns the day of the week of the currently displayed date. Read-only property.

Usage

[form.]control.DayOfWeek

Remarks

If the date/time edit control is not currently displaying a valid date (ie it is blank),  then this property returns a negative value.

This property returns an integer value between 0 and 6:  0=Sunday, 1=Monday, ..., 6=Saturday

Data Type

Integer


Format Property

Specifies the format of the date/time text that will be displayed in the control.

Usage

[form.]control.Format [ = stringexpression ]

Remarks

This property allows you to specify how you want the date/time to be displayed using a string expression similar to the built-in functions Format and Format$.

The following table shows the characters you can use to create user-defined date/time formats and the meaning of each.

Character	Meaning

d	Display the day as a number without a leading zero (1-31).

dd	Display the day as a number with a leading zero (01-31).

ddd	Display the day of the week as an abbreviation (Sun-Sat).

dddd	Display the day of the week as a full name (Sunday-Saturday).

ddddd	Display the date as a complete date (including day, month and year) formatted according to the Short Date setting in the International section of the Windows Control Panel.

dddddd	Display the date as a complete date (including day, month and year) formatted according to the Long Date setting in the International section of the Windows Control Panel.

m	Display the month as a number without a leading zero (1-12). If m immediately follows h or hh, the minute rather than the month is displayed.

mm	Display the month as a number with a leading zero (01-12). If mm immediately follows h or hh, the minute rather than the month is displayed.

mmm	Display the month as an abbreviation (Jan-Dec).

mmmm	Display the month as a full month name (January-December).

yy	Display the year as a two digit number (00-99).

yyyy	Display the year as a four digit number (1900-2099).

h	Display the hour as a number without leading zeros (0-23).

hh	Display the hour as a number with leading zeros (00-23).

n	Display the minute as a number without leading zeros (0-59).

nn	Display the minute as a number with leading zeros (00-59).

s	Display the second as a number without leading zeros (0-59).

ss	Display the second as a number with leading zeros (00-59).

ttttt	Display the time as a complete time (including hour, minute and optional second  see TimeResolution property) formatted using the time format defined in the International section of the Control Panel.

ampm	Use the 12-hour clock and display the contents of the 1159 string in the Internation section of the Control Panel if the time is before noon, and use the 2359 string defined in the Internation section of the Control Panel if the time is after noon.

The following table lists some examples of valid formats:

Format	Display

m/d/yy	11/14/94

d-mmmm-yy	14-November-94

d mmmm	14 November

mmmm yy	November 94

hh:mm ampm	06:49 PM

h:mm	18:49

dddddd ttttt	Monday 14 November, 1994 6:49:30 PM


FormatOption Property (Obsolete)

Note	This property is obsolete as of version 3.0 of the DTEDIT.VBX custom control. It has been replaced by the Format property. This property has been retained for backwards compatibility, but it is no longer visible at design time.

Determines the format of the date/time text that will be displayed in the control.

Usage

[form.]control.FormatOption [ = numericexpression ]

Remarks

Valid values for the FormatOption property are shown in the following table.

FormatOption	Meaning

0	(Default) Display date and time

1	Display date only

2	Display time only

Data Type

Integer


Hour Property

Returns the hour of the currently displayed date/time. Read-only property.

Usage

[form.]control.Hour

Remarks

If the date/time edit control is not currently displaying a valid date/time (ie it is blank),  then this property returns a negative value.

Data Type

Integer


KeyboardEntry Property

Specifies whether alpha-numeric keyboard keys may be used to specify the date.

Usage

[form.]control.KeyboardEntry [ = numericexpression ]

Remarks

Default value is True.

If this property is set to False, the only way to modify the value of the date/time is via the up/down arrow keys and the spin buttons.

Data Type

Integer (Boolean)


Language Property

Specifies the language that day and month names will be displayed in.

Usage

[form.]control.Language [ = stringexpression ]

Remarks

When set to the value Default or (Default),  the language displayed is specified by the international settings on the Windows control panel.

The language may be set to any of the strings listed below (either the long form or the abbreviation) to explicitly set the language:

Long form	Abbreviation(s)

Danish	dan

Dutch	nld

English	eng, enu

Finnish	fin

French	fra

French Canadian	frc

German	deu

Icelandic	isl

Italian	ita

Norwegian	nor

Portuguese	ptg

Spanish	esn, esp

Swedish	sve, swe


Minute Propery
Minute Property

Returns the minute of the currently displayed date/time. Read-only property.

Usage

[form.]control.Minute

Remarks

If the date/time edit control is not currently displaying a valid date/time (ie it is blank),  then this property returns a negative value.

Data Type

Integer


Month Property

Returns the month of the currently displayed date/time.  Read-only property.

Usage

[form.]control.Month

Remarks

If the date/time edit control is not currently displaying a valid date/time (ie it is blank),  then this property returns a negative value.

Data Type

Integer


Second Property

Returns the second of the currently displayed date/time. Read-only property.

Usage

[form.]control.Second

Remarks

If the date/time edit control is not currently displaying a valid date/time (ie it is blank),  then this property returns a negative value.

Data Type

Integer


ShowButtons Property

Specifies whether the spin buttons are displayed.

Usage

[form.]control.ShowButtons [ = numericexpression ]

Remarks

Default value is True.

If this property is set to False, the only way to modify the value of the date/time is via the keyboard.

Data Type

Integer (Boolean)


TimeResolution Property

Defines the resolution to which times are to be displayed. This property only has meaning if the Format property contains the format string ttttt, specifying time of day formatted according to the International section of the Control Panel.

Different applications have different requirements for time resolutions. Some applications need to show time to a resolution of one second. Other applications are only concerned with time up to a resolution of one minute.

Usage

[form.]control.TimeResolution [ = numericexpression ]

Remarks

Valid values for the TimeResolution property are shown in the following table.

TimeResolution	Meaning

0	(Default) Display time to a resolution of one second

1	Display time to a resolution of one minute

Data Type

Integer


TimeSerial Property

Returns the currently displayed time as a time serial number compatible with the VB TimeSerial function.  Read-only property.

Usage

[form.]control.TimeSerial

Remarks

If the date/time edit control is not currently displaying a valid date/time (ie it is blank),  then this property returns a negative value.

Data Type

Single


TimeStep Property

Defines the amount of time to increment and decrement by.

In many applications, it is convenient to increment and decrement the date/time in a specific unit of time. For example, in a timesheet application it may be convenient to increment and decrement in units of 10 minutes.

Usage

[form.]control.TimeStep[ = numericexpression ]

Remarks

In the following example display, setting the TimeStep property to 5 means that the time will be incremented/decremented by 5 minutes whenever a spin button is pressed.

This property is not applicable if the Format property specifies that only dates are to be displayed.


Text Property

The text property provides a mechanism to both read and set the date/time that is displayed in the control.

Usage

[form.]control.Text[ = stringexpression ]

Remarks

When setting the Text property, the value must be a valid date/time, otherwise a run-time error will result. This control recognises a wide range of date time formats. All of the following strings are recognised as a valid date value.

•	15/3/94

•	15th March 94

•	Mar 15 1994

•	1994.3.15

When reading the Text property, the value is always in the format specified by the Format property.

If the Text property is set to an empty string, then no date or time is displayed.

If the Text property is set to an invalid date/time value, then a run-time error is invoked.

Note	The Text property for this custom control differs from the normal text property in that it is settable only at run-time.

See Also

Discussion of Text property in Visual Basic Language Reference.


WrapAround Property

Specifies how the displayed date/time is incremented and decremented. If set to True, then incrementing a date/time field past its maximum allowed value causes the date/time to wrap around rather than increment. The default value is False.

Usage

[form.]control.WrapAround [ = numericexpression ]

Remarks

Some applications require the fields of the displayed date/time to increment using a cumulative method  for example if the displayed date is 31 March 1994 and the day is incremented, then the displayed date is 1 April 1994. (This method is used in previous versions of the DTEDIT.VBX control).

Other applications may require the individual fields of the displayed date to wrap around without modifying other fields of the displayed date. For example if the displayed date is 31 March 1994 and the day is incremented, then the displayed date is 1 March 1994. (This method is used in the Date/Time section of the Control Panel).

Data Type

Integer (Boolean)


Year Property

Returns the year of the currently displayed date/time. Read-only property.

Usage

[form.]control.Year

Remarks

If the date/time edit control is not currently displaying a valid date/time (ie it is blank),  then this property returns a negative value.

Data Type

Integer


Change Event

Indicates that the contents of the date/time control have changed. This event occurs whenever one of the following happen:

•	Either of the spin buttons are pressed, incrementing or decrementing the value of the date/time.

•	The "Up" or "Down" cursor key is pressed, incrementing or decrementing the value of the date/time.

•	Another key is pressed that modifies the contents of the selected date part.

Syntax

Sub ctlname_Change(Index As Integer)

Remarks

The argument Index uniquely identifies a control if it is in a control array. A change procedure can synchronize or coordinate data display among controls. Or you might use a change procedure to validate that a date/time is within a permitted range (eg only dates less than today).

See Also

Discussion of Change event in Visual Basic Language Reference.


New Features

The following features have been added in version 3.1 of the Date/Time Edit VB Custom Control:

•	International language support.  Control displays dates in the language specified in the 'International' section of the windows control panel.  If desired, this language may be overridden by the Language property.

•	New properties for reading the current date/time displayed on the control: DayOfWeek, DayOfMonth, Month, Year, Hour, Minute,. Second, DateSerial, TimeSerial

•	Supports the following standard VB events: MouseUp, MouseDown, MouseMove, DragDrop, DragOver

•	Supports the following standard VB properties: DragMode, DragIcon

•	Supports the following standard VB events: Clear, Drag

•	Control displays different appearance when disabled

Features added in V3.0


Features added in V3.0

The following features were added in version 3.0 from version 2.1:

•	Added flexibility in specifying the format of the displayed date/time. The new Format accepts a format string similar to that accepted by the built-in function Format and Format$.

•	New properties KeyboardEntry, ShowButtons and WrapAround.

•	Control is now data-aware.

•	Improved display of date/time format at design time.

•	Improved screen-painting  only modified fields are repainted.


Ordering Information

You can purchase a registered copy of DTEDIT.VBX via either of the following methods:

CompuServe

To have the registration fee added to your compuServe bill, type "GO SWREG" and follow the menus. The registration ID for DTEDIT.VBX is 3582.  Purchase price is USD $29.95 per copy of DTEDIT.VBX plus USD $3.00 shipping and handling.

Fax

Print out the fax order form and fill in the details.  Fax to the number printed on the fax order form.  Purchase will be charged against your credit card in Australian Dollars at a price of AUD $38.90 for each copy of DTEDIT.VBX, plus a charge of AUD $3.90 Shipping & handling.  These conversions are based on an exchange rate of AUD $1.00 = USD $0.77, but the actual exchange rate fluctuates slightly on a daily basis.

Australian Dollars (AUD)	Equivalent U.S. Dollars (USD)
38.90	29.95
3.90	3.00


Fax Order Form
DTEDIT.VBX Fax Order Form

To print this order form, click on 'Print Topic' in the 'File' menu.

To:	Pragma Pty Ltd	Fax No:	(International)	+61-7-841-1977

20 Ingluna Circuit	(Australia)	(07) 841-1977

Eight Mile Plains QLD 4113

AUSTRALIA

Please Supply

______  copies of DTEDIT.VBX at AUD $38.90 each =	AUD $	_______

Shipping and handling	AUD $     3.90

Total	AUD $  _______

Deliver To

Name:	___________________________________________________________

Company:	___________________________________________________________

Address:	___________________________________________________________

City:	_________________________________________   State:  ___________

Country:	_________________________________  Post Code / Zip: ____________

Fax No:	_________________________  E-mail: ____________________________

Credit Card Details

Credit Card Type (circle one):	Visa	Mastercard

Cardholder's Name:	________________________________________________________

Credit Card Number:	________________________________	Expiry Date:  ____ / ____

Cardholder's Signature:______________________________________